//package com.hzw.saas.web.sso.controller;
//
//import cn.hutool.core.util.StrUtil;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.hzw.saas.common.config.util.PageParam;
//import com.hzw.saas.common.config.util.PageUtils;
//import com.hzw.saas.web.sso.pojo.dto.SaasClientDto;
//import com.hzw.saas.web.sso.pojo.model.SaasClient;
//import com.hzw.saas.web.sso.pojo.param.SaasClientParam;
//import com.hzw.saas.web.sso.service.ISaasClientService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiOperationSort;
//import io.swagger.annotations.ApiSort;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import ma.glasnost.orika.MapperFacade;
//import org.springframework.http.ResponseEntity;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * <p>
// *  第三方客户端管理接口
// * </p>
// *
// * @author sonam
// * @since 2021/3/1 14:43
// */
//@Slf4j
//@RestController
//@ApiSort(value = 3)
//@RequiredArgsConstructor
//@Api(tags = "鸿之微/客户端接口")
//@RequestMapping("/saas/client")
//public class SaasClientController {
//
//    @Resource(name = "saasClientServiceImpl")
//    private ISaasClientService saasClientService;
//    private final MapperFacade mapperFacade;
//
//    @GetMapping("/")
//    @ApiOperation(value = "分页获取第三方应用信息")
//    @ApiOperationSort(1)
//    public ResponseEntity<IPage<SaasClientDto>> getByPage(PageParam pageParam) {
//        Page<SaasClient> saasClientPage = saasClientService.page(pageParam.convert(),
//            Wrappers.<SaasClient>lambdaQuery().orderByDesc(SaasClient::getCreateDate));
//        return ResponseEntity.ok(PageUtils.convert(saasClientPage, SaasClientDto.class));
//    }
//
//    @PostMapping("/")
//    @ApiOperation(value = "注册第三方应用信息")
//    @ApiOperationSort(2)
//    public ResponseEntity<String> submit(@Validated @RequestBody SaasClientParam saasClientParam) {
//        SaasClient saasClient = mapperFacade.map(saasClientParam, SaasClient.class);
//        List<String> authorizedGrantTypes = saasClientParam.getAuthorizedGrantTypes();
//        List<String> resourceIds = saasClientParam.getResourceIds();
//        saasClient.setScope("all"); // 目前写死
//        saasClient.setAuthorities(StrUtil.join(",", authorizedGrantTypes.toArray()));
//        saasClient.setAuthorities(StrUtil.join(",", resourceIds.toArray()));
//        saasClientService.registerSaasClient(saasClient);
//        return ResponseEntity.ok("注册成功");
//    }
//
//}
